import Vue from 'vue'
import App from './App.vue'
import {createRouter} from './router'
import {createStore} from './store'

Vue.config.productionTip = false
Vue.mixin({
  beforeMount(){
    //在vue实例中拿到asyncData也就是在this.$options
    const {asyncData} = this.$options;
    if(asyncData){
      this.dataPromise = asyncData({
        store:this.$store,
      })
    }
  }
})
export function createApp(context){
  const router = createRouter()
  const store = createStore()
  const app = new Vue({
    router,
    context,
    store,
    render: h => h(App)
  })
  return {app,router,store}
}

